package com.itheima.reggie.common;

/**
 * <b><code>BaseContext</code></b>
 * <p/>
 * 基于ThreadLocal封装工具类，用于保存和获取当前登录用户id
 * 作用范围：某一个线程之内
 * <p/>
 * <b>Creation Time:</b> 24/06/2024 11:22.
 *
 * @author yanjr
 * @since reggie_take_out
 */
public class BaseContext {
    private static ThreadLocal<Long> threadLocal = new ThreadLocal<>();

    public static void setCurrentUser(Long id) {
        threadLocal.set(id);
    }

    public static Long getCurrentUser() {
        return threadLocal.get();
    }
}
